package com.lbb.springboot.util;


import com.baomidou.mybatisplus.core.toolkit.IdWorker;

/**
 * @author likanghong
 * @date 2018/3/27 16:17
 */
public class IdUtil {


    /**
     * 订单号
     */
    public static String getOrderNo() {
        return String.valueOf(IdWorker.getId());
    }

    /**
     * 收款号
     */
    public static String getReceiptNo() {
        return String.valueOf(IdWorker.getId());
    }

    /**
     * 退款号
     */
    public static String getRefundNo() {
        return String.valueOf(IdWorker.getId());
    }


    public static synchronized String getPrivateId() {
        String nowTimeStr = DateUtil.getNowTimeStr();
        StringBuffer sb = new StringBuffer();
        sb.append("sk");
        sb.append(nowTimeStr);
        sb.append(IdWorker.get32UUID().substring(0, 13));
        return sb.toString();
    }

    public static synchronized String getPrivateOrderNo() {
        String nowTimeStr = DateUtil.getNowTimeStr();
        StringBuffer sb = new StringBuffer();
        sb.append("sko");
        sb.append(nowTimeStr);
        sb.append(IdWorker.get32UUID().substring(0, 13));
        return sb.toString();
    }

    public static synchronized String getOrderNo(String start) {
        String nowTimeStr = DateUtil.getNowTimeStr();
        StringBuffer sb = new StringBuffer();
        sb.append(start);
        sb.append(nowTimeStr);
//        sb.append(IdWorker.get32UUID().substring(0, 5));
        return sb.toString();
    }

    public static synchronized String getLeagueId() {
        String nowTimeStr = DateUtil.getNowTimeStr();
        StringBuffer sb = new StringBuffer();
        sb.append("tk");
        sb.append(nowTimeStr);
        sb.append(IdWorker.get32UUID().substring(0, 13));
        return sb.toString();
    }

    public static synchronized String getLeagueOrderNo() {
        String nowTimeStr = DateUtil.getNowTimeStr();
        StringBuffer sb = new StringBuffer();
        sb.append("tko");
        sb.append(nowTimeStr);
        sb.append(IdWorker.get32UUID().substring(0, 13));
        return sb.toString();
    }

    public static synchronized String getLeagueScheduleId() {
        String nowTimeStr = DateUtil.getNowTimeStr();
        StringBuffer sb = new StringBuffer();
        sb.append("tkpq");
        sb.append(nowTimeStr);
        sb.append(IdWorker.get32UUID().substring(0, 13));
        return sb.toString();
    }

    public static synchronized String getId() {
        return IdWorker.get32UUID();
    }

}
